package com.ndjh.stb;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/**
 * 必须要在com.ndjh.stb包名下
 * @author dongming
 *
 */
public class libsecurity
{
	/**
	 * 机顶盒信息
	 */
	private static String _deviceName = "YW9300";
	private static String _productName = "full_smdk4x12";
	private static String _productDevice = "smdk4x12";
	public static native int verify_device();
	
    static {
        System.loadLibrary("verifycode");
    }	
    
	public static boolean AuthorVerify() {
		// 获取当前设备型号
		Process ifc = null;
		try {
			// 标准方式获取设备型号
			ifc = Runtime.getRuntime().exec("getprop ro.device.model");
			BufferedReader bis = new BufferedReader(new InputStreamReader(ifc.getInputStream()));
			String deviceName = bis.readLine().toString().trim();

			ifc = Runtime.getRuntime().exec("getprop ro.product.name");
			bis = new BufferedReader(new InputStreamReader(ifc.getInputStream()));
			String productName = bis.readLine().toString().trim();

			ifc = Runtime.getRuntime().exec("getprop ro.product.device");
			bis = new BufferedReader(new InputStreamReader(ifc.getInputStream()));
			String productDevice = bis.readLine().toString().trim();
			
			if (_deviceName.equals(deviceName) && _productName.equals(productName) && _productDevice.equals(productDevice) && (libsecurity.verify_device() > 0)) {
				return true;
			}
			
		} catch (IOException e) {
			e.printStackTrace();
		} finally {
			if (ifc != null) {
				ifc.destroy();
			}
		}
		return false;
	}
}